<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        const arr = ["孙悟空", "猪八戒", "沙和尚"]

        // const arr2 = arr  // 不是复制
        // arr2[0] = "唐僧"

        // 如何去复制一个对象 复制必须要产生新的对象
        // 当调用slice时，会产生一个新的数组对象，从而完成对数组的复制
        const arr3 = arr.slice()


        // console.log(arr === arr2)
        // console.log(arr2)

        arr3[0] = "唐僧"

        console.log(arr)
        console.log(arr3)

    </script>
</head>
<body>
    
</body>
</html>